<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('角色列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="role-form">
                <div class="select-list">
                    <ul>
                        <li>
                            模型名称：<input type="text" name="moduleName"/>
                        </li>
                        <li>
                            发布状态：
                            <select id="onlineStatus" required th:with="type=${@dict.getType('online_status')}" th:name="onlineStatus">
                                <option value="">--选择发布状态查询--</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            模型类别：
                            <select id="typeId" required th:with="type=${moduleTypes}" th:name="typeId">
                                <option value="">--选择模型分类查询--</option>
                                <option th:each="dict : ${type}" th:text="${dict.typeName}" th:value="${dict.id}"></option>
                            </select>
                        </li>
                        <li class="select-time">
                            <label>创建时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]" />
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]" />
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:dataModule:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:dataModule:remove')}]];
    var datas = [[${@dict.getType('online_status')}]];
    var prefix = ctx + "system/DataModule";

    var prefix1 = ctx + "system/userModel";

    function submitHandler(index, layero) {
        var rows = $.table.selectColumns("id");
        var rowsName = $.table.selectColumns("moduleName");
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.close();
        // 父页面的方法
        // parent.selectUsers();
        // 父页面的变量
        parent.$("#modelName").val(rowsName.join());
        parent.$("#moduleIds").val(rows.join());
        console.log(rowsName.join() + "-----" + rows.join())
    }

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            //sortName: "roleSort",
            modalName: "数据模型",
            showSearch: false,
            showToggle: false,
            pagination: false,
            showRefresh: false,
            showColumns: false,
            columns: [{
                radio: true
            },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'moduleName',
                    title: '模型名称',
                    sortable: true
                },
                {
                    field: 'typeName',
                    title: '模型类别'
                },
                {
                    field: 'picUrl',
                    title: '模型封面URL',
                    formatter: function(value, row, index) {
                        // 图片预览（注意：如存储在本地直接获取数据库路径，如有配置context-path需要使用ctx+路径）
                        // 如：/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
                        return $.table.imageView(ctx + value);
                    }
                },
                {
                    field: 'onlineStatus',
                    title: '发布状态',
                    sortable: true,
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'createName',
                    title: '创建人名称',
                    sortable: true
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable: true
                },
                {
                    field: 'updateName',
                    title: '更新人名称',
                    sortable: true
                },
                {
                    field: 'updateTime',
                    title: '更新时间',
                    sortable: true
                }]
        };
        $.table.init(options);
    });

    function showUserModel(id,moduleName){

        $.modal.openTab("moduleName相关元素",prefix1+"?moduleId="+id)
    }




</script>
</body>
</html>